#include "texturemanager.h"
#include "texture.h"
#include "jxex_lib/stringutil.h"

TextureManager::TextureManager()
	: ResourceManager(emTYPE_TEXTURE, "Texture")
{	}

TextureManager::~TextureManager()
{
	Destroy();
}

Texture* TextureManager::CreateManual(const String& strName,
	ManualLoader* pLoader,
	const KSize cSize,
	PixelFormat emFormat /* = emPIXEL_A8R8G8B8 */,
	TextureUsage emUsage /* = emTEXTUREUSAGE_DEFAULT */,
	HardwarePool emPool /* = emPOOL_MANAGED */)
{
	Texture* pTexture = (Texture*)Create(strName, true, pLoader, NULL);
	if (pTexture)
	{
		pTexture->SetPixelFormat(emFormat);
		pTexture->SetPool(emPool);
		pTexture->SetUsage(emUsage);
		pTexture->SetSize(cSize);
	}

	return pTexture;
}

Texture* TextureManager::CreateByFile(const String& strFile,
	const KSize& cSize/* = KSize(0, 0)*/,
	PixelFormat emFormat/* = emPIXEL_A8R8G8B8*/,
	TextureUsage emUsage/* = emTEXTUREUSAGE_DEFAULT*/,
	HardwarePool emPool/* = emPOOL_MANAGED*/)
{
	Texture* pTexture = (Texture*)Create(strFile, false, NULL, NULL);
	if (pTexture)
	{
		pTexture->SetPixelFormat(emFormat);
		pTexture->SetPool(emPool);
		pTexture->SetUsage(emUsage);
		pTexture->SetSize(cSize);
	}
	
	return pTexture;
}
